#ifndef __dynamicH__
#define __dynamicH__

#include "kernel.h"
#include "game.h"

namespace WtfEngine
{
	class IDynamic : public virtual IGcObject
	{
	public:
		virtual void Update() = 0;
		
		virtual void Init();
		virtual void Destroy();
		
		GC_INTERFACE(IDynamic);
	};

	class ObjectUpdater : public Task<ObjectUpdater>
	{
	public:
		typedef std::set<IDynamic::tRef>	tUpdateList;
		typedef std::set<IDynamic::tRef>	tRemoveList;

	private:
		tUpdateList	UpdateList;
		tRemoveList RemoveList;

	public:
		ObjectUpdater()
			: Task<ObjectUpdater>(0, "Object Updater") {};

		inline void PushObject(const IDynamic::tRef& rObj) {
			RemoveList.erase(rObj);
			UpdateList.insert(rObj);
		};

		inline void RemoveObject(const IDynamic::tRef& rObj) {
			RemoveList.insert(rObj);
		};
		
		void Run();
	};
};

#endif

